Component({
    properties: {},
    data: {
        ids: [11, 22, 33],
        name: [
            ["11-name1", "11-name2", "11-name3"],
            ["22-name1", "22-name2", "22-name3"],
            ["33-name1", "33-name2", "33-name3"]
        ],
        selectedValue: [0, 0],
        isHiddenPicker: true,
        currentSelectedValue: [0, 0]
    },
    methods: {
        pickerChange(e) {
            const selectedIndex = e.detail.value
            console.log("选择的值是：", this.data.ids[selectedIndex])
        },
        showPicker() {
            this.setData({
                isHiddenPicker: !this.data.isHiddenPicker
            })
        },
        pickerViewChange(e) {
            // 获取上一次选中的索引值
            const lastTimeSelectedValue = this.data.selectedValue
            // 获取当前选中的索引值
            let currentSelectedValue = e.detail.value

            // 选中左侧时，右侧从0开始
            const selectedValue = [currentSelectedValue[0], 0]

            // 只有当左侧发生切换时才设置选中的值
            if (lastTimeSelectedValue[0] !== currentSelectedValue[0]) {
                this.setData({
                    selectedValue,
                    currentSelectedValue: selectedValue
                })
            } else {
                this.setData({
                    currentSelectedValue
                })
            }
        },
        confirmPicker() {
            const currentSelectedValue = this.data.currentSelectedValue
            console.log("左侧选中的值：", this.data.ids[currentSelectedValue[0]])
            console.log("右侧选中的值：", this.data.name[currentSelectedValue[0]][currentSelectedValue[1]])
        }
    }
});
